import pyautogui
 
def capture(self):
    screen_all = pyautogui.screenshot()
    screen_all.save('screenshot.png', 'png')

 

if __name__ == '__main__':
    # 获取当前打开窗口
    capture(None)